// pages/personal/personal.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 'personal',
    user: {
      avatar: 'http://localhost:8080/image/petHealth/pet1.jpg',
      displayName: '111',
      authenticationStatus: '身份证明验证',     
    },
    currentTab: 'posted',
  },  

   userInfo() {
    try {
      
      console.log(wx.getStorageSync('userInfo'));
      this.setData({
        'user.avatar': wx.getStorageSync('userInfo').avatarUrl,
        'user.displayName': wx.getStorageSync('userInfo').nickName,
      });
    } catch (err) {
      console.error(err);
    }
  },
  

  goToFavorites() {
    // Implement logic to navigate to the Favorites page
  },
  goToReviews() {
    // Implement logic to navigate to the Reviews page
  },
  goToSettings(){
    wx.navigateTo({
      url: '/pages/setting/setting',
    })
  },

  goToAuthentication() {
    // Implement logic to navigate to the authentication page
    wx.navigateTo({
      url: '/pages/authentication/authentication', // Replace with the URL of the authentication page
    });
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.userInfo();
  },

  showPostedTransactions() {
    // Navigate to the registration page
    wx.switchTab({
      url: '/pages/rentPet/rentPet', // Replace with the URL of the registration page
    });
  },

  logout() {
    wx.navigateTo({
      url: '/pages/load/load',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  switchTab(event) {
    const targetTab = event.currentTarget.dataset.tab;
    if (this.data.currentTab !== targetTab) {
      wx.switchTab({
        url: `/pages/${targetTab}/${targetTab}`
      });
    }
  }
})